package com.zmj.sy.mom.srv.aps.utils;

import java.util.HashMap;
import java.util.Map;

public class DrawingUtils {

    static Map<String, String> linkMap = new HashMap<>();

    static {
        linkMap.put("01", "D");
        linkMap.put("02", "Y");
        linkMap.put("03", "Z");
    }


    public static String toDxfFtpPath(String topMaterCode, String plmId) {
        return "ftp://172.31.3.31" + toDxfPath(topMaterCode, plmId);
    }

    /**
     * 根据顶层plm的ID获取dxf文件的路径
     *
     * @param topMaterCode
     * @param plmId
     * @return
     */
    public static String toDxfPath(String topMaterCode, String plmId) {
        int len = plmId.length() - "_170".length();

        if (!plmId.endsWith("_170")) {
            len = len + "_170".length();
        }

        String newFileName = plmId.substring(0, len) + "-XL_170.dxf";
        return toDxfDir(topMaterCode) + newFileName.toUpperCase();
    }

    /**
     * 根据顶层plm的ID获取dxf文件的目录
     *
     * @param topMaterCode
     * @return
     */
    public static String toDxfDir(String topMaterCode) {
        String[] split = topMaterCode.split("-");
        String parentDir = String.join("-", split[0], split[1]);

        return "/dxf-CuttingDiagram/" + parentDir + "/" + topMaterCode + "/";
    }

    /**
     * 获取标准件路径
     * @return
     */
    public static String getCommonPartPath() {
        return "/dxf-CuttingDiagram/000-commons/";
    }
}
